// -------------------------------------------------------------------------
//    @FileName         :    NFCNetServerModule.h
//    @Author           :    GaoYi
//    @Date             :    2017-10-16
//    @Module           :    NFCNetServerModule
//
// -------------------------------------------------------------------------

#pragma once

#include <iostream>
#include <iosfwd>
#include "NFCNet.h"
#include "NFComm/NFCore/NFQueue.hpp"
#include "NFComm/NFCore/NFConsistentHash.hpp"
#ifdef _MSC_VER
#pragma warning(disable: 4244 4267)
#endif
#include "NFComm/NFMessageDefine/NFDefine.pb.h"
#ifdef _MSC_VER
#pragma warning(default: 4244 4267)
#endif
#include "NFComm/NFPluginModule/NFINetServerModule.h"
#include "NFComm/NFPluginModule/NFINetModule.h"
#include "NFComm/NFPluginModule/NFIPluginManager.h"

class NFCNetServerModule : public NFINetServerModule
{
public:
    NFCNetServerModule(NFIPluginManager* p);

    virtual bool Init();
    virtual bool AfterInit();
    virtual bool BeforeShut();
    virtual bool Shut();
    virtual bool Execute();
public:
    virtual int ExpandBufferSize(const unsigned int size = 1024 * 1024 * 20);
public:
    virtual int AddReceiveCallBack(const NF_SERVER_TYPES eType, NET_RECEIVE_FUNCTOR_PTR functorPtr);
    virtual int AddReceiveCallBack(const NF_SERVER_TYPES eType, const int nMsgID, NET_RECEIVE_FUNCTOR_PTR functorPtr);
    virtual int AddEventCallBack(const NF_SERVER_TYPES eType, NET_EVENT_FUNCTOR_PTR functorPtr);
public:
    virtual int Initialization(const NF_SERVER_TYPES eType, const unsigned int nServerID, const unsigned int nMaxClient, const unsigned short nPort, const int nCpuCount);
public:
    virtual NFINetModule* GetServerNetInfo(const NF_SERVER_TYPES eType);
protected:
    void    ProcessExecute();
private:
    int mnBufferSize;

    //server_type, server_data
    NFMap<int, NFINetModule> mxServerMap;
};

